var _serviceURL = '/69mark/web';// 必须设置
$(function() {
	doPage(1);
});

function doPage(page){
	var bNickName = $("#bNickName").val();
	var mNickName = $("#mNickName").val();
	var orderNumber = $("#orderNumber").val();
	var orderState = $("#orderState").val();
	var isPay = $("#isPay").val();
	$.ajax({
   		type : "POST",
   		url : _serviceURL+"/toListAllOrder.do",
   		cache : false,
   		data : "pageNo="+page+"&pageSize=10&bNickName="+bNickName+"&mNickName="+mNickName+"&orderNumber="+orderNumber+"&orderState="+orderState+"&isPay="+isPay,
   		dataType : 'json',
   		success : function(data) {
   			var result = "";
   			for(var i=0;i<data.menuList.length;i++){
   				
   				var t=data.menuList[i].created_time.time;
   				var d=	new Date();
   				d.setTime(t);
   				var date=d.format('yyyy-MM-dd HH:mm:ss');
   				
   				result += "<tr>";
   				result += "<td>"+data.menuList[i].bNickName+"</td>";
   				result += "<td>"+data.menuList[i].mNickName+"</td>";
   				result += "<td>"+data.menuList[i].order_number+"</td>";
   				result += "<td>"+date+"</td>";
   				result += "<td>"+data.menuList[i].money+"</td>";
   				result += "<td>"+data.menuList[i].order_days+"天</td>";
   				/*result += "<td>"+data.menuList[i].money+"</td>";*/
   				
   				//订单状态 0:无状态，等待BOSS下单 1:待确认,BOSS申请，等待秘书接单 2:订单生效，秘书已经接单，但是开始时间未到 3:服务中，开始时间到了 4:结束
   				if (data.menuList[i].order_state == 1) {
   					result += "<td>秘书未接单</td>";
   				}else if (data.menuList[i].order_state == 2) {
   					result += "<td>未开始</td>";
   				}else if (data.menuList[i].order_state == 3) {
   					result += "<td>进行中</td>";
   				}else if (data.menuList[i].order_state == 4) {
   					result += "<td>已完成</td>";
   				}
   				
   				if (data.menuList[i].is_pay == 0) {
   					result += "<td>未付款</td>";
   				}else {
   					result += "<td>已付款</td>";
   				}
   				   				
   				result += "<td>";
   				result += "<a href=\""+_serviceURL+"/toOrderInformIndex.do?orderId="+data.menuList[i].order_id+"\" title=\"查看\">查看</a>";
   				result += "<a href=\""+_serviceURL+"/toOrderrichen.do?orderId="+data.menuList[i].order_id+"\" style=\"margin-left: 10px;\" title=\"日程\">日程</a>";
   				result += "</td>";
   				result += "</tr>";
   			}
   			
   			$("#listUser").html(result);
   			$("#page_user").html(data.navi);
   			
   			$("#bNickName").val("");
   			$("#mNickName").val("");
   			$("#orderNumber").val("");
   			$("#orderState").val("");
   			$("#isPay").val("");
   		}
	})
	
}

Date.prototype.format=function(fmt) {
    var o = {        
    "M+" : this.getMonth()+1, //月份        
    "d+" : this.getDate(), //日        
    "h+" : this.getHours()%12 == 0 ? 12 : this.getHours()%12, //小时        
    "H+" : this.getHours(), //小时        
    "m+" : this.getMinutes(), //分        
    "s+" : this.getSeconds(), //秒        
    "q+" : Math.floor((this.getMonth()+3)/3), //季度        
    "S" : this.getMilliseconds() //毫秒        
    };        
    var week = {        
    "0" : "\u65e5",        
    "1" : "\u4e00",        
    "2" : "\u4e8c",        
    "3" : "\u4e09",        
    "4" : "\u56db",        
    "5" : "\u4e94",        
    "6" : "\u516d"       
    };        
    if(/(y+)/.test(fmt)){        
        fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));        
    }        
    if(/(E+)/.test(fmt)){        
        fmt=fmt.replace(RegExp.$1, ((RegExp.$1.length>1) ? (RegExp.$1.length>2 ? "\u661f\u671f" : "\u5468") : "")+week[this.getDay()+""]);        
    }        
    for(var k in o){        
        if(new RegExp("("+ k +")").test(fmt)){        
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));        
        }        
    }        
    return fmt;        
} 

//审核状态查询
function orderState(orderState) {
	$("#orderState").val(orderState);
	doPage(1);
}

//性别查询
function isPay(isPay) {
	$("#isPay").val(isPay);
	doPage(1);
}

//用户名查询
function serchName() {
	doPage(1);
}

function delfuncitem(thisid){
    layer.confirm('确定删除？',{btn:['确定','取消']},function(){
        $.ajax({
            type:'POST',
            url:_serviceURL+'/toDeleteBossId.do',
            data:'userId='+thisid,
            dataType : 'json',
            success:function(flag){
                if(flag==1){
                    layer.msg('删除成功',{
                        time: 2000,
                    });
                    doPage(1);
                 }else{
                     layer.msg('删除失败',{
                        time: 2000,
                      });
                 }
             }
         });
      });
 }


